import request from '@/utils/request'


//首页推荐列表
export function getRecommendList(data) {
  return new Promise((resolve, reject) => {
    request({
      url: '/api/poster.category/index',
      method: 'get',
      data
    }).then(data => {
      resolve(data)
    }).catch((e) => {
		console.log(e);
      reject(e)
    })
  })
}
//轮播
export function getSwiperList(data) {
  return new Promise((resolve, reject) => {
    request({
      url: '/api/page/banner',
      method: 'get',
      data
    }).then(data => {
      resolve(data)
    }).catch((e) => {
      reject(e)
    })
  })
}
//模板列表
export function getmodulelist(data) {
  return new Promise((resolve, reject) => {
	  	if(data.name==''){
			request({
			  url: `/api/poster/list?page=${data.page}&erjifenlei=${data.erjifenlei}&erjifenlei=${data.erjifenlei}`,
			  method: 'get',
			  data
			}).then(data => {
			  resolve(data)
			}).catch((e) => {
			  reject(e)
			})
			}else{
				request({
				  url: `/api/poster/list?page=${data.page}&erjifenlei=${data.erjifenlei}&erjifenlei=${data.erjifenlei}&name=${data.name}`,
				  method: 'get',
				  data
				}).then(data => {
				  resolve(data)
				}).catch((e) => {
				  reject(e)
				})
			}
 
  })
}
//模块详情
export function moduledeteils(data) {
  return new Promise((resolve, reject) => {
    request({
      url: `/api/poster/detail?id=${data}`,
      method: 'get',
      data
    }).then(data => {
      resolve(data)
    }).catch((e) => {
      reject(e)
    })
  })
}
//海报分类列表
export function categoryList(data) {
  return new Promise((resolve, reject) => {
    request({
      url:`/api/poster.category/list?page=${data}`,
      method: 'get',
      data
    }).then(data => {
      resolve(data)
    }).catch((e) => {
      reject(e)
    })
  })
}

//字体列表
export function typefaceList(data) {
  return new Promise((resolve, reject) => {
    request({
      url:'/api/poster.typeface/list',
      method: 'get',
      data
    }).then(data => {
      resolve(data)
    }).catch((e) => {
      reject(e)
    })
  })
}
//换一批
export function getSutcategoryList(id) {
  return new Promise((resolve, reject) => {
    request({
      url:`/api/poster/rand?categoryId=${id}`,
      method: 'get',
     
    }).then(data => {
      resolve(data)
    }).catch((e) => {
      reject(e)
    })
  })
}